package cn.wolfcode.java39.api._07_filter;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class Producer {
    public static void main(String[] args) throws Exception {
        //1 . 创建一个生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("wolfcode-producer-java39");
        //2 . 设置nameserver的地址
        producer.setNamesrvAddr("192.168.12.129:9876;192.168.12.128:9876");
        //3 . 启动生产者
        producer.start();
        //4 . 创建一个message对象
        Message message = new Message("07-filter","TagA","hello-rocket".getBytes("utf-8"));
        message.putUserProperty("name","lolo");
        message.putUserProperty("age","18");
        message.putUserProperty("hight","172");
        //5 . 使用同步的方式放松
        SendResult sendResult = producer.send(message);
        System.out.println(sendResult.getSendStatus());
        System.out.println(sendResult.getMsgId());
        //6 . 关闭生产者
        producer.shutdown();
    }
}
